package ex5;
import java.awt.Container;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.*;
public class Mywindow extends JFrame{
	 Mywindow() {
		 this.setTitle("窗口");
		 this.setBounds(0, 0, 800, 600);
		 this.setVisible(true);
		 this.setResizable(false);
		 this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
		 JButton btn=new JButton("隐藏");
		 btn.setBounds(10, 20, 200,100);
		  Container c=this.getContentPane();
		  JLabel label=new JLabel();
		  label.setBounds(10, 20, 200, 300);
		   label.setText("这是一个文本");
    		   c.add(btn);
    		   c.setLayout(null);
    		   c.add(label);
    		   btn.addActionListener(new ActionListener() {
    	        	@Override
    	        	public void actionPerformed(ActionEvent e) {
    	        		label.setVisible(false);
    	        	}
    	        });
		 
	}
	
	
	
	public static void main(String[] args) {
	   new Mywindow();

	}

}
